package week2.day8;

import java.util.regex.Pattern;

public class Account {
    private String username;
    private String password;
    private double balance;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        if (Pattern.matches("^\\w{4,6}$", username)) {
            this.username = username;
        } else {
            throw new IllegalArgumentException("用户名长度必须在4-6位之间");
        }
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        if (Pattern.matches("^\\w{6}$", password)) {
            this.password = password;
        } else {
            throw new IllegalArgumentException("密码长度必须为6位");
        }
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        if (balance > 100) {
            this.balance = balance;
        } else {
            throw new IllegalArgumentException("余额必须大于100");
        }
    }
}
